import 'dart:io';
import 'package:baidu_map_test/flutter_map_demo.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bmfbase/BaiduMap/map/bmf_map_sdk.dart';
import 'package:flutter_bmfbase/BaiduMap/map/bmf_types.dart';
import 'package:bdmap_location_flutter_plugin/bdmap_location_flutter_plugin.dart';


void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  void initState() {
    if (Platform.isIOS) {
      BMFMapSDK.setApiKeyAndCoordType(
          'uFuOo2A79UdSEgycZ6BwctPIdgB0m1p8', BMF_COORD_TYPE.BD09LL);
      LocationFlutterPlugin.setApiKey("uFuOo2A79UdSEgycZ6BwctPIdgB0m1p8");
    }else{
      BMFMapSDK.setCoordType(BMF_COORD_TYPE.BD09LL);
    }
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: FlutterBMFMapDemo(),
    );
  }
}
